<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户信息管理</title>
     <%@include file="/common/include.jsp"%>
     	<script>
		$(function(){
			$('#userList').treegrid({
				//title:'用户列表',
				pagination:true,
				idField:'id',
				treeField:'names',
				singleSelect:false,
				frozenColumns:[[
				    {field:'ck',checkbox:true},
				    {title:'名称',field:'names',width:"200"}
				]],
				toolbar:[{
					text:'确定选择',
					iconCls:'icon-ok',
					handler:function(){
						okSel();
					}
				},'-',{
					text:'返回',
					iconCls:'icon-cancel',
					handler:function(){
						okSel();
					}
				},'-',{
					text:'查询',
					iconCls:'icon-search',
					handler:function(){
					    $('#userList').treegrid('options').url = 'commAction!getUserTreeGridJSON.action?isSearch=true&_query.names='+$('#names').val();
					    $('#userList').treegrid("reload");

					}
				}],
				onLoadSuccess:function(){
					$('.datagrid-toolbar').append($('#searchTable'));
					$('#searchTable').show();
				   	var userListPager = $(this).datagrid('getPager');
					if (userListPager){	
						$(userListPager).pagination({
							showPageList:false,
							showRefresh:false,
							displayMsg:'第一级{from}-{to},共{total}'
						});
					};
				}
			});
		});

		function okSel(){
			var selectedRows = $('#userList').treegrid('getSelections');
			if (selectedRows.length>0){
				for(var i=0; i<selectedRows.length; i++){
					var ids = selectedRows[i].id+'';
					if(ids.indexOf("M")==-1)
					parent.selectUser();
				}
		    }else{
		    	$.messager.alert('提示信息','<div style="padding-top:15px;padding-left:5px"><b>请选择一条数据！</b></div>','warning');
		    }
		}

	</script>
</head>
<body class="easyui-layout">
  <div region="center" border="false">
	<table id="userList" fit="true" url="commAction!getUserTreeGridJSON.action">
		<thead>
			<tr>
				<th field="userClass" width="80">用户类型</th>
				<th field="postion" width="100">职务</th>
			</tr>
		</thead>
	</table>
   <table id="searchTable" style="display:none" border="0" cellpadding="0">
	<tr>
	    <td width="30%">
			<B><input type="text" id="names" style="width:80px"/></B>
		</td>
		<td width="70%">
			<B>用户名称</B>
		</td>	
	<tr>
 </table>	
 </div>
</body>
</html>